#include "inCheck.h"

extern Square board[10][10];
extern Square *whiteKing;
extern Square *blackKing;

bool in_check(Color player)
{
	Square *king;
	Color otherPlayer;
	Square *temp;

	if(player == WHITE) {
		king = whiteKing;
		otherPlayer = BLACK;
	} 
        
        else {
		king = blackKing;
		otherPlayer = WHITE;
	}

	for(int i=1; i <= 9; i++) {
		for(int j=1; j<=9; j++) {
			temp = &board[i][j];
			if(temp->color == otherPlayer) {
				if(is_legal_move(temp, king))
					return true;
			}
                }
	}

	return false;
}
/*
bool canAttack(Square *attacker, Square *target)
{
	return false;
}*/
